package com.blockmeta.bbs.businesslibrary.widget;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.blockmeta.bbs.businesslibrary.R;


/**
 * @author AirThor
 * @date 2019/3/7.
 */
public class CircleGradeAndKind extends FrameLayout{
    private TextView mGrade,mKind,mKind1;

    public CircleGradeAndKind(@NonNull Context context) {
        super(context);
        init(context);
    }

    public CircleGradeAndKind(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context){
        inflate(context, R.layout.view_circle_grade_kind,this);
        mGrade = findViewById(R.id.tv_circle_grade);
        mKind = findViewById(R.id.tv_circle_kind);
        mKind1 = findViewById(R.id.tv_circle_kind1);
    }

    public void setText(String grade,String kind){
        if (TextUtils.isEmpty(grade)||"0".equals(grade)){
            mGrade.setVisibility(GONE);
            mKind.setVisibility(GONE);
            mKind1.setVisibility(VISIBLE);

            mKind1.setText(kind);
        }else {
            mGrade.setVisibility(VISIBLE);
            mKind.setVisibility(VISIBLE);
            mKind1.setVisibility(GONE);

            mGrade.setText(grade);
            mKind.setText(kind);
        }
    }
}
